﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="PropertyList.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.PropertyList" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <div class="contentDiv">
    <table width="100%">
    <% foreach (RealEstateProperty rep in dc.RealEstateProperties.Where<RealEstateProperty>(r=>r.Deleted==false))
       { %>
        <tr>
            <td style="text-align:left; border-bottom-style:dashed; border-bottom-color:Silver; border-bottom-width:1pt;">
                <% if (rep.Photos.Count > 0)
                   {
                       Photo f = rep.Photos.Where<Photo>(foto => foto.Deleted == false).Take<Photo>(1).SingleOrDefault<Photo>(); %>
                    <img src='../Repository/<%= f.FileName %>' height="120" width="120" alt="" />
                <% } else { %>
                    <label style="text-align:center; font-size:.7em">No photo available</label>
                <%} %>
            </td>
            <td style="border-bottom-style:dashed; border-bottom-color:Silver; border-bottom-width:1pt; text-align:left">
                <ul style="text-align:left">
                    <li>Location:&nbsp;<%= rep.Location.Name %></li>
                    <li>Price:&nbsp;<%= String.Format("{0:C}", rep.Price) %></li>
                    <li>
                        <a href='<%= Url.Action("EditProperty", new { Controller = "Admin", propertyId = rep.PropertyId })%>'>Edit</a>
                        <a onclick="javascript:return confirm('Delete this property?')" href='<%= Url.Action("DeleteProperty", new { Controller = "Admin", propertyId = rep.PropertyId })%>'>Delete</a>
                    </li>
                </ul>
            </td>
        </tr>
            
    <%} %>
    </table>
</div>
</asp:Content>
